Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Answers for OCJP / SCJP Online Test | Mock Test

←Go Back to Online Practice Test

Ques.

What is the output for the below code?

package bean;

public class Abc {
    public static int index_val = 10;
}

 

package com;
import static bean.Abc.index_val;

public class Test1 {
    public static void main(String... args) {
        System.out.println(index_val);
    }
}


Option 1.

10

Option 2.

compile error, index_val not defined

Option 3.

Compile error at import static bean.Abc.index_val;

Option 4.

None of the above


Ans. Option 1

Please provide the reason below. The best provided reason will be displayed with your name(if you are logged-in) on website.
Enter Reason
 
Is it helpful? Yes No
©2024 WithoutBook